package com.wsjc.common.core.dao.db;

import java.util.Map;

import com.wsjc.common.core.enums.MunicipalEnum;

/**
 * 表路由
 * @author 93733
 *
 */
public class TableRoute {
	
	/**
	 * 表 以市级水平分表，直辖市按照区级
	 * @param params
	 * @param areaId
	 */
	public static void setTableName(Map<String, Object> params, String areaId){
		
		String provinceId = areaId.substring(0, 2)+"0000";
    	MunicipalEnum municipalEnum = MunicipalEnum.getEnum("P"+provinceId);
    	if(null != municipalEnum){
    		params.put("tableName", params.get("tableName")+areaId);
    	}else{
    		String cityId = areaId.substring(0, 4)+"00";
    		params.put("tableName", params.get("tableName")+cityId);
    	}
    	
	}

	/**
	 * 得到表名
	 * @param dataTableNameSterilization
	 * @param areaId
	 */
	public static String getTableName(String tableName, String areaId) {
		
		String provinceId = areaId.substring(0, 2)+"0000";
    	MunicipalEnum municipalEnum = MunicipalEnum.getEnum("P"+provinceId);
    	if(null != municipalEnum){
    		return tableName+areaId;
    	}else{
    		String cityId = areaId.substring(0, 4)+"00";
    		return tableName+cityId;
    	}
		
	}
	
	
	

}
